package org.springblade.message.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.mp.base.BaseEntity;

import java.time.LocalDateTime;

/**
 * 消息详情表实体类
 *
 * @author weikun
 * @since 2021-05-08
 */
@Data
@TableName("blade_message")
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "Message对象", description = "消息详情表")
public class Message extends BaseEntity {

	private static final long serialVersionUID = 1L;



	/**
	 * 消息发送记录id
	 */
	@ApiModelProperty(value = "消息发送记录id")
	private Long messageLogId;

	/**
	 * 类型
	 */
	@ApiModelProperty("类型")
	private Integer type;

	/**
	 * 标题
	 */
	@ApiModelProperty(value = "标题")
	private String title;

	/**
	 * 内容
	 */
	@ApiModelProperty(value = "内容")
	private String content;

	/**
	 * 接收人
	 */
	@ApiModelProperty(value = "接收人id")
	private Long receiveUser;

	/**
	 * 是否已读
	 */
	@ApiModelProperty(value = "是否已读")
	private Integer isRead;

	/**
	 * 已读时间
	 */
	@ApiModelProperty(value = "已读时间")
	private LocalDateTime readTime;

	/**
	 * 接收群
	 */
	@TableField(exist = false)
	@ApiModelProperty(value = "接收群")
	private Long receiveGroup;

	/**
	 * 创建人姓名
	 */
	@TableField(exist = false)
	@ApiModelProperty(value = "创建人姓名")
	private String createUserName;

	public Message(){}

	public Message(MessageLog messageLog) {
		this.type=messageLog.getType();
		this.title= messageLog.getTitle();
		this.messageLogId=messageLog.getId();
		this.content= messageLog.getContent();
		this.receiveUser=messageLog.getReceiveUser();
		super.setCreateTime(messageLog.getCreateTime());
		super.setCreateUser(messageLog.getCreateUser());
	}
}
